home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / var / lib / dpkg / info / rsyslog.postinst < prev    next >
Encoding:
Text File  |  2010-11-30  |  2.5 KB  |  99 lines

  1. #!/bin/sh
  2.  
  3. set -e
  4.  
  5. # summary of how this script can be called:
  6. #        * <postinst> `configure' <most-recently-configured-version>
  7. #        * <old-postinst> `abort-upgrade' <new version>
  8. #        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
  9. #          <new-version>
  10. #        * <postinst> `abort-remove'
  11. #        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
  12. #          <failed-install-package> <version> `removing'
  13. #          <conflicting-package> <version>
  14. # for details, see http://www.debian.org/doc/debian-policy/ or
  15. # the debian-policy package
  16.  
  17. rotate_old_log_files()
  18. {
  19.     log_files="syslog mail.info mail.warn mail.err mail.log daemon.log \
  20.                kern.log auth.log user.log lpr.log cron.log debug messages"
  21.     skipped_files=""
  22.     dir=/var/log
  23.  
  24.     for f in $log_files; do
  25.         if [ -e $dir/$f.0 ]; then
  26.             rotate="yes"
  27.             if [ -e $dir/$f.1.gz ]; then
  28.                 date0=$(stat --format=%Y $dir/$f.0)
  29.                 date1=$(stat --format=%Y $dir/$f.1.gz)
  30.                 if [ $date0 -lt $date1 ] ; then
  31.                     # .0 log file is older than .1
  32.                     skipped_files="$dir/$f.0\n$skipped_files"
  33.                     rotate="no"
  34.                 fi
  35.             fi
  36.             if [ "$rotate" = "yes" ] ; then
  37.                 for s in $(seq 9 -1 1) ; do
  38.                     if [ -e $dir/$f.$s.gz ]; then
  39.                         mv $dir/$f.$s.gz $dir/$f.$(($s+1)).gz
  40.                     fi
  41.                 done
  42.                 mv $dir/$f.0 $dir/$f.1
  43.             fi
  44.         fi
  45.     done
  46.     if [ -n "$skipped_files" ]; then
  47.         printf "The following old log files were found which could not be rotated safely.\n"
  48.         printf "\n$skipped_files\n"
  49.         printf "Please inspect them manually and delete them, if no longer required.\n"
  50.     fi
  51. }
  52.  
  53.  
  54. case "$1" in
  55.     configure)
  56.     # Rotate .0 log files when migrating from sysklogd
  57.     if dpkg --compare-versions "$2" lt "3.18.5-1"; then
  58.         rotate_old_log_files
  59.     fi
  60.  
  61.     # Update init script priorities
  62.     if dpkg --compare-versions "$2" lt "3.20.2-1"; then
  63.         for i in 0 6 ; do
  64.             if [ -e /etc/rc$i.d/K90rsyslog ]; then
  65.                 mv /etc/rc$i.d/K90rsyslog /etc/rc$i.d/S30rsyslog
  66.             fi
  67.         done
  68.     fi
  69.     ;;
  70.  
  71.     abort-upgrade|abort-remove|abort-deconfigure)
  72.     ;;
  73.  
  74.     *)
  75.     echo "postinst called with unknown argument \`$1'" >&2
  76.     exit 1
  77.     ;;
  78. esac
  79.  
  80.  
  81. # Automatically added by dh_installinit
  82. if [ -x "/etc/init.d/rsyslog" ]; then
  83.     update-rc.d rsyslog start 10 2 3 4 5 . start 30 0 6 . stop 90 1 . >/dev/null
  84.     if [ -n "$2" ]; then
  85.         _dh_action=restart
  86.     else
  87.         _dh_action=start
  88.     fi
  89.     if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
  90.         invoke-rc.d rsyslog $_dh_action || exit $?
  91.     else
  92.         /etc/init.d/rsyslog $_dh_action || exit $?
  93.     fi
  94. fi
  95. # End automatically added section
  96.  
  97.  
  98. exit 0
  99.